package com.echat.elocation.protocol.entity;

public class PackageMsg {

    /**
     * 消息头 16byte
     */
    protected MsgHeader msgHeader;

    /**
     * 消息体字节数组
     */
    protected byte[] msgBody;

    /**
     * 检验码 1byte
     */
    protected int checkCode;

    public MsgHeader getMsgHeader() {
        return msgHeader;
    }

    public void setMsgHeader(MsgHeader msgHeader) {
        this.msgHeader = msgHeader;
    }

    public byte[] getMsgBody() {
        return msgBody;
    }

    public void setMsgBody(byte[] msgBody) {
        this.msgBody = msgBody;
    }

    public int getCheckCode() {
        return checkCode;
    }

    public void setCheckCode(int checkCode) {
        this.checkCode = checkCode;
    }

    public static class MsgHeader {

        // 消息id
        protected int msgId;

        //////// =====消息体属性
        //byte[2-3]
        protected int msgBodyProps;
        // 消息体长度
        protected int msgBodyLength;
        // 数据加密方式
        protected int encryptionType;
        // 是否分包,true==>有消息包封装项
        protected boolean hasSubPackage;
        // 保留位[14-15]
        protected String reservedBit;
        //////// =====消息体属性

        // 手机号
        protected String phoneNumber;
        //流水号
        protected int flowId;

        //////// =====消息包封装项
        // byte[12-15]
        protected int packageInfoField;
        // 消息包总数(word(16))
        protected long totalSubPackage;
        // 包序号(word(16))这次发送的这个消息包是分包中的第几个消息包, 从 1 开始
        protected long subPackageSeq;
        //////// =====消息包封装项


        public int getMsgId() {
            return msgId;
        }

        public void setMsgId(int msgId) {
            this.msgId = msgId;
        }

        public int getMsgBodyProps() {
            return msgBodyProps;
        }

        public void setMsgBodyProps(int msgBodyProps) {
            this.msgBodyProps = msgBodyProps;
        }

        public int getMsgBodyLength() {
            return msgBodyLength;
        }

        public void setMsgBodyLength(int msgBodyLength) {
            this.msgBodyLength = msgBodyLength;
        }

        public int getEncryptionType() {
            return encryptionType;
        }

        public void setEncryptionType(int encryptionType) {
            this.encryptionType = encryptionType;
        }

        public boolean isHasSubPackage() {
            return hasSubPackage;
        }

        public void setHasSubPackage(boolean hasSubPackage) {
            this.hasSubPackage = hasSubPackage;
        }

        public String getReservedBit() {
            return reservedBit;
        }

        public void setReservedBit(String reservedBit) {
            this.reservedBit = reservedBit;
        }

        public String getPhoneNumber() {
            return phoneNumber;
        }

        public void setPhoneNumber(String phoneNumber) {
            this.phoneNumber = phoneNumber;
        }

        public int getFlowId() {
            return flowId;
        }

        public void setFlowId(int flowId) {
            this.flowId = flowId;
        }

        public int getPackageInfoField() {
            return packageInfoField;
        }

        public void setPackageInfoField(int packageInfoField) {
            this.packageInfoField = packageInfoField;
        }

        public long getTotalSubPackage() {
            return totalSubPackage;
        }

        public void setTotalSubPackage(long totalSubPackage) {
            this.totalSubPackage = totalSubPackage;
        }

        public long getSubPackageSeq() {
            return subPackageSeq;
        }

        public void setSubPackageSeq(long subPackageSeq) {
            this.subPackageSeq = subPackageSeq;
        }

        @Override
        public String toString() {
            return "MsgHeader{" +
                    "msgId=" + msgId +
                    ", msgBodyAttribute=" + msgBodyProps +
                    ", msgBodyLength=" + msgBodyLength +
                    ", encryptionType=" + encryptionType +
                    ", hasSubPackage=" + hasSubPackage +
                    ", reservedBit='" + reservedBit + '\'' +
                    ", phoneNumber='" + phoneNumber + '\'' +
                    ", serialNumber=" + flowId +
                    ", packageInfoField=" + packageInfoField +
                    ", totalSubPackage=" + totalSubPackage +
                    ", subPackageSeq=" + subPackageSeq +
                    '}';
        }
    }
}
